# Maintainer: Natanael Copa <ncopa@alpinelinux.org>
pkgname=conntrack-tools
pkgver=1.4.8
pkgrel=0
pkgdesc="Connection tracking userspace tools"
url="https://www.netfilter.org/projects/conntrack-tools/"
arch="all"
license="GPL-2.0-or-later"
subpackages="$pkgname-doc $pkgname-openrc"
makedepends="
	bison
	flex
	libmnl-dev
	libnetfilter_conntrack-dev
	libnetfilter_cthelper-dev
	libnetfilter_cttimeout-dev
	libnetfilter_queue-dev
	libnfnetlink-dev
	libtirpc-dev
	linux-headers
	"
source="https://www.netfilter.org/projects/conntrack-tools/files/conntrack-tools-$pkgver.tar.xz
	conntrackd.initd
	conntrackd.confd
	conntrackd.logrotate
	"
options="!check"

build() {
	export CFLAGS="$CFLAGS -D_GNU_SOURCE $(pkgconf --cflags libtirpc)"
	export LDFLAGS="$LDFLAGS $(pkgconf --libs libtirpc)"

	./configure \
		--build=$CBUILD \
		--host=$CHOST \
		--prefix=/usr
	make
}

package() {
	make DESTDIR="$pkgdir" install

	install -Dm755 "$srcdir"/conntrackd.initd "$pkgdir"/etc/init.d/conntrackd
	install -Dm644 "$srcdir"/conntrackd.confd "$pkgdir"/etc/conf.d/conntrackd
	install -Dm644 doc/stats/conntrackd.conf \
		"$pkgdir"/etc/conntrackd/conntrackd.conf
	install -Dm644 "$srcdir"/conntrackd.logrotate \
		"$pkgdir"/etc/logrotate.d/conntrackd
}

sha512sums="
95d8f6f068c1342ad7e767537e722272a4f5bd8b46b952713ade053a1043aa9ababbe5ce658ede9c77b6de5221b97ad8833777caffd69b67dd70a99f2b45afdf  conntrack-tools-1.4.8.tar.xz
f1d96a8107ff1f95b626d592121b59104a3a013970cad8112fde237db2db514d1383e520adf46bf1384831d8d91ec943838a9391b32c3d1ce2bf6aa83c86e18d  conntrackd.initd
fd8cfab207867844db6671a8395efadca792d6085c3436381e574dc52f3b4e41d9526b3db6114dd98e534a5419ca19f291d21c091f8cf0426024d73d18133e6f  conntrackd.confd
1e4e6414bbf4210fab83d1a8cd7198bf11f2638d378abd674b1b66bd6ab6bdc048fc4052c3e263bd02dfc8085d007f3092f24e818f8579a940aa3b5af19c1766  conntrackd.logrotate
"
